let code = null;
const readline = require("readline");

function aiFun(callback) {
  //创建readline接口实例
  let rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
  });

  // question方法
  rl.question("请输入amazon code    ", function (answer) {
    code = answer;
    console.log("code is：" + answer);
    // 不加close，则不会结束
    rl.close();
  });

  // close事件监听
  rl.on("close", function () {
    // 结束程序
    // process.exit(0);
    callback(code);
  });
}

module.exports = aiFun;
